package com.newviews.tcmip.web.controller;

import com.newviews.tcmip.common.model.PageModel;
import com.newviews.tcmip.common.model.ResultModel;

import com.newviews.tcmip.pojo.vo.EtcmCommonBaseInfoRespVO;
import com.newviews.tcmip.service.inf.EtcmIngrServiceInf;
import com.newviews.tcmip.web.vo.etcmherb.statistics.HerbStatisticsRespVo;
import com.newviews.tcmip.web.vo.etcmingr.EtcmBarChartRespVo;
import com.newviews.tcmip.web.vo.etcmingr.EtcmScatterDiagramRespVo;
import com.newviews.tcmip.web.vo.etcmingr.EtcmVolcanoMapRespVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.constraints.NotBlank;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 组成成分 前端控制器
 * </p>
 *
 * @author lxc
 * @since 2024-02-29
 */
@RestController
@RequestMapping("/etcm/ingr")
@Api(tags = "组成成分")
public class EtcmIngrController {
    @Resource
    private EtcmIngrServiceInf etcmIngrServiceInf;

    @GetMapping("/page")
    @ApiOperation("成分信息：查询")
    public ResultModel<PageModel<Map<String,String>>>getPage(@RequestParam(required = false) String content,
                                                             @RequestParam @NotBlank(message = "语言编码不能为空") String langCode,
                                                             @RequestParam @NotBlank(message = "ui编码不能为空") String uiTypeCode,
                                                             @RequestParam(required = false, defaultValue = "1") Integer pageNo,
                                                             @RequestParam(required = false) String property,
                                                             @RequestParam(required = false, defaultValue = "10") Integer pageSize,
                                                             @RequestParam(required = false, defaultValue = "desc") String sortType){

        return etcmIngrServiceInf.getPage(langCode,uiTypeCode,pageNo, pageSize, content,sortType,property);
    }

    @ApiOperation(value = "成分：统计")
    @GetMapping("/statistics")
    public ResultModel<Map<String,String>> getStatistics(@RequestParam(required = false) String content){
        return etcmIngrServiceInf.getStatistics(content);
    }

    @GetMapping("/details")
    @ApiOperation("成分信息：详情")
    public ResultModel<List<EtcmCommonBaseInfoRespVO>>getDetails(@RequestParam @NotBlank(message = "id不能为空") String ingrId,
                                                                      @RequestParam @NotBlank(message = "语言编码不能为空") String langCode,
                                                                      @RequestParam @NotBlank(message = "ui编码不能为空") String uiTypeCode){
        return etcmIngrServiceInf.getDetails(ingrId,langCode,uiTypeCode);
    }


    @ApiOperation(value = "成分构成：相关靶向查询")
    @GetMapping("/target/page")
    public ResultModel<PageModel<Map<String,String>>> getPageByTarget(@RequestParam @NotBlank(message = "语言编码不能为空") String langCode,
                                                                      @RequestParam @NotBlank(message = "ui编码不能为空") String uiTypeCode,
                                                                      @RequestParam @NotBlank(message = "中草药id不能为空") String ingrId,
                                                                      @RequestParam(required = false, defaultValue = "1") Integer pageNo,
                                                                      @RequestParam(required = false, defaultValue = "10") Integer pageSize,
                                                                      @RequestParam(required = false) String content,
                                                                      @RequestParam(required = false) String type,
                                                                      @RequestParam(required = false, defaultValue = "desc") String sortType){
        return etcmIngrServiceInf.getPageByTarget(langCode,uiTypeCode,ingrId,pageNo, pageSize, content,type,sortType);
    }

    @GetMapping("/target/statistics")
    @ApiOperation("获取成分靶向统计")
    public ResultModel<Map<String,String>> getTargetStatistics(@RequestParam(required = false) String content,
                                                               @RequestParam String ingrId){

        return etcmIngrServiceInf.getTargetStatistics(content, ingrId);
    }


    @ApiOperation(value = "成分组学信息：查询")
    @GetMapping("/experimental/records/page")
    public ResultModel<PageModel<Map<String,String>>> getPageByExperimentalRecords(@RequestParam @NotBlank(message = "语言编码不能为空") String langCode,
                                                                                   @RequestParam @NotBlank(message = "ui编码不能为空") String uiTypeCode,
                                                                                   @RequestParam @NotBlank(message = "中草药id不能为空") String ingrId,
                                                                                   @RequestParam(required = false, defaultValue = "1") Integer pageNo,
                                                                                   @RequestParam(required = false, defaultValue = "10") Integer pageSize,
                                                                                   @RequestParam(required = false) String content,
                                                                                   @RequestParam(required = false, defaultValue = "desc") String sortType){
        return etcmIngrServiceInf.getPageByExperimentalRecords(langCode,uiTypeCode,ingrId,pageNo, pageSize, content,sortType);
    }

    @ApiOperation(value = "成分组合用药关系：协同成分查询")
    @GetMapping("/synergistic/ingredients/page")
    public ResultModel<PageModel<Map<String,String>>> getPageBySynergisticIngredients(@RequestParam @NotBlank(message = "语言编码不能为空") String langCode,
                                                                                      @RequestParam @NotBlank(message = "ui编码不能为空") String uiTypeCode,
                                                                                      @RequestParam @NotBlank(message = "中草药id不能为空") String ingrId,
                                                                                      @RequestParam(required = false, defaultValue = "1") Integer pageNo,
                                                                                      @RequestParam(required = false, defaultValue = "100") Integer pageSize,
                                                                                      @RequestParam(required = false, defaultValue = "desc") String sortType,
                                                                                      @RequestParam(required = false) String content){
        return etcmIngrServiceInf.getPageBySynergisticIngredients(langCode,uiTypeCode,ingrId,pageNo, pageSize, content,sortType);
    }


    @ApiOperation(value = "成分组合用药关系：相关的疾病查询")
    @GetMapping("/associated/diseases/page")
    public ResultModel<PageModel<Map<String,String>>> getPageByAssociatedDiseases(@RequestParam @NotBlank(message = "语言编码不能为空") String langCode,
                                                                                  @RequestParam @NotBlank(message = "ui编码不能为空") String uiTypeCode,
                                                                                  @RequestParam @NotBlank(message = "中草药id不能为空") String ingrId,
                                                                                  @RequestParam(required = false, defaultValue = "1") Integer pageNo,
                                                                                  @RequestParam(required = false, defaultValue = "100") Integer pageSize,
                                                                                  @RequestParam(required = false, defaultValue = "desc") String sortType,
                                                                                  @RequestParam(required = false) String content){
        return etcmIngrServiceInf.getPageByAssociatedDiseases(langCode,uiTypeCode,ingrId,pageNo, pageSize, content,sortType);
    }



    @ApiOperation(value = "成分：相关的处方查询")
    @GetMapping("/px/page")
    public ResultModel<PageModel<Map<String,String>>> getPageByPx(@RequestParam @NotBlank(message = "语言编码不能为空") String langCode,
                                                                  @RequestParam @NotBlank(message = "ui编码不能为空") String uiTypeCode,
                                                                  @RequestParam @NotBlank(message = "中草药id不能为空") String ingrId,
                                                                  @RequestParam(required = false, defaultValue = "1") Integer pageNo,
                                                                  @RequestParam(required = false, defaultValue = "10") Integer pageSize,
                                                                  @RequestParam(required = false, defaultValue = "desc") String sortType,
                                                                  @RequestParam(required = false) String content){
        return etcmIngrServiceInf.getPageByPx(langCode,uiTypeCode,ingrId,pageNo, pageSize, content,sortType);
    }


    @ApiOperation(value = "成分：相关的中草药查询")
    @GetMapping("/herb/page")
    public ResultModel<PageModel<Map<String,String>>> getPageByHerb(@RequestParam @NotBlank(message = "语言编码不能为空") String langCode,
                                                                    @RequestParam @NotBlank(message = "ui编码不能为空") String uiTypeCode,
                                                                    @RequestParam @NotBlank(message = "中草药id不能为空") String ingrId,
                                                                    @RequestParam(required = false, defaultValue = "1") Integer pageNo,
                                                                    @RequestParam(required = false, defaultValue = "10") Integer pageSize,
                                                                    @RequestParam(required = false) String content,
                                                                    @RequestParam(required = false) String herbFlavorCode,
                                                                    @RequestParam(required = false) String herbPropertyCode,
                                                                    @RequestParam(required = false) String herbMeridiansCode,
                                                                    @RequestParam(required = false, defaultValue = "desc") String sortType){
        return etcmIngrServiceInf.getPageByHerb(langCode,uiTypeCode,ingrId,pageNo, pageSize, content,herbFlavorCode,herbPropertyCode,herbMeridiansCode,sortType);
    }


    @GetMapping("/admet/details")
    @ApiOperation(value = "成分转运关系：详情",notes = "ADMET：ADMET properties")
    public ResultModel<List<EtcmCommonBaseInfoRespVO>>getAdmetDetails(@RequestParam @NotBlank(message = "id不能为空") String ingrId,
                                                                           @RequestParam @NotBlank(message = "语言编码不能为空") String langCode,
                                                                           @RequestParam @NotBlank(message = "ui编码不能为空") String uiTypeCode,
                                                                           @RequestParam(required = false, defaultValue = "1") Integer pageNo,
                                                                           @RequestParam(required = false, defaultValue = "10") Integer pageSize,
                                                                           @RequestParam(required = false) String content){
        return etcmIngrServiceInf.getAdmetDetails(ingrId,langCode,uiTypeCode,pageNo,pageSize,content);
    }



//    @ApiOperation(value = "成分组合用药关系：相关文献查询")
//    @GetMapping("/treatise/page")
//    public ResultModel<PageModel<Map<String,String>>> getPageByTreatise(@RequestParam @NotBlank(message = "语言编码不能为空") String langCode,
//                                                                        @RequestParam @NotBlank(message = "ui编码不能为空") String uiTypeCode,
//                                                                        @RequestParam @NotBlank(message = "中草药id不能为空") String ingrId,
//                                                                        @RequestParam(required = false, defaultValue = "1") Integer pageNo,
//                                                                        @RequestParam(required = false, defaultValue = "10") Integer pageSize,
//                                                                        @RequestParam(required = false) String content){
//        return etcmIngrServiceInf.getPageByTreatise(langCode,uiTypeCode,ingrId,pageNo, pageSize, content);
//    }


    @GetMapping("/volcano/map")
    @ApiOperation(value = "组学：火山图")
    public ResultModel<EtcmVolcanoMapRespVo>getVolcanoMap(@RequestParam @NotBlank(message = "编码不能为空") String erId){
        return etcmIngrServiceInf.getVolcanoMap(erId);
    }

    @GetMapping("/scatter/diagram")
    @ApiOperation(value = "组学：散点图")
    public ResultModel<EtcmScatterDiagramRespVo>getScatterDiagram(@RequestParam @NotBlank(message = "编码不能为空") String erId){
        return etcmIngrServiceInf.getScatterDiagram(erId);
    }

    @GetMapping("/bar/chart")
    @ApiOperation(value = "组学：柱状图")
    public ResultModel<EtcmBarChartRespVo>getBarChart(@RequestParam @NotBlank(message = "编码不能为空") String erId){
        return etcmIngrServiceInf.getBarChart(erId);
    }
}
